/**
 * Copyright (c) 2006-2007 Jinyi.lu
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of GNU LGPL license by gun.org
 * which accompanies this distribution, and is available at
 * http://gnu.feld-it.at/copyleft/lesser.html
 * 
 * Project Homepage : http://code.google.com/p/demou
 * Source Code: svn checkout http://demou.googlecode.com/svn/trunk/ demou
 * Mailing list : jinyi.lu@gmail.com
 *                stonelu@126.com
 *
 *  
 * Contributors:
 *     JinYi.Lu - initial API and implementation
 */
package cn.tworen.demou.handler;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import cn.tworen.demou.cmd.CmdName;
import cn.tworen.demou.cmd.ICmd;
import cn.tworen.demou.cmd.IInvokeCmd;
import cn.tworen.demou.handler.invoke.CloseStream;
import cn.tworen.demou.handler.invoke.Connect;
import cn.tworen.demou.handler.invoke.CreateStream;
import cn.tworen.demou.handler.invoke.DeleteStream;
import cn.tworen.demou.handler.invoke.Disconnect;
import cn.tworen.demou.handler.invoke.FunctionCall;
import cn.tworen.demou.handler.invoke.IInvoke;
import cn.tworen.demou.handler.invoke.Pause;
import cn.tworen.demou.handler.invoke.Play;
import cn.tworen.demou.handler.invoke.Publish;
import cn.tworen.demou.handler.invoke.Seek;
import cn.tworen.demou.rtmp.Client;

/**
 * Created on  2007-1-21
 *
 * Title       : InvokeHandler.java
 * Description : 
 * 
 * @author     : LuJinYi
 * @version    : 1.0
 * @Date       : 2007-1-21
 * History     : 
 * 
 */
public class InvokeHandler implements IListener {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger
			.getLogger(InvokeHandler.class);
	
	private final Map<CmdName, IInvoke> invokeMap = new HashMap<CmdName, IInvoke>();
	public void recevie(Client client, ICmd cmd) {
		invokeMap.get(((IInvokeCmd)cmd).getCmdName()).invoke(client, (IInvokeCmd)cmd);
	}
	public IInvoke getListener(CmdName name){
		return invokeMap.get(name);
	}
	public void setListener(CmdName name, IInvoke listener) {
		this.invokeMap.put(name, listener);
	}

}
